package c.j.a.d.b.n;

import android.os.Build;
import android.text.TextUtils;
import c.b.a.a.a;
import c.j.a.d.b.b.e;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/* compiled from: RomUtils */
public class d0 {
    public static String a = null;
    public static String b = "";
    public static String c = "";
    public static String d;
    public static String e;
    public static String f;
    public static String g;

    public static boolean a() {
        return b("EMUI");
    }

    public static boolean b(String str) {
        l();
        String str2 = d;
        if (str2 != null) {
            return str2.equals(str);
        }
        str2 = c("ro.miui.ui.version.name");
        e = str2;
        if (TextUtils.isEmpty(str2)) {
            str2 = c("ro.build.version.emui");
            e = str2;
            if (TextUtils.isEmpty(str2)) {
                str2 = c(b);
                e = str2;
                if (TextUtils.isEmpty(str2)) {
                    str2 = c("ro.vivo.os.version");
                    e = str2;
                    if (TextUtils.isEmpty(str2)) {
                        str2 = c("ro.smartisan.version");
                        e = str2;
                        if (TextUtils.isEmpty(str2)) {
                            str2 = c("ro.gn.sv.version");
                            e = str2;
                            if (TextUtils.isEmpty(str2)) {
                                str2 = c("ro.lenovo.lvp.version");
                                e = str2;
                                if (TextUtils.isEmpty(str2)) {
                                    String str3 = "SAMSUNG";
                                    if (i().toUpperCase().contains(str3)) {
                                        d = str3;
                                        f = "com.sec.android.app.samsungapps";
                                    } else {
                                        str3 = "ZTE";
                                        if (i().toUpperCase().contains(str3)) {
                                            d = str3;
                                            f = "zte.com.market";
                                        } else {
                                            str3 = "NUBIA";
                                            if (i().toLowerCase().contains(str3)) {
                                                d = str3;
                                                f = "cn.nubia.neostore";
                                            } else {
                                                str2 = Build.DISPLAY;
                                                e = str2;
                                                str3 = "FLYME";
                                                if (str2.toUpperCase().contains(str3)) {
                                                    d = str3;
                                                    f = "com.meizu.mstore";
                                                } else {
                                                    e = "unknown";
                                                    d = Build.MANUFACTURER.toUpperCase();
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    d = "LENOVO";
                                    f = "com.lenovo.leos.appstore";
                                }
                            } else {
                                d = "QIONEE";
                                f = "com.gionee.aora.market";
                            }
                        } else {
                            d = "SMARTISAN";
                            f = "com.smartisanos.appstore";
                        }
                    } else {
                        d = "VIVO";
                        f = "com.bbk.appstore";
                    }
                } else {
                    d = a;
                    f = c;
                }
            } else {
                d = "EMUI";
                f = "com.huawei.appmarket";
            }
        } else {
            d = "MIUI";
            f = "com.xiaomi.market";
        }
        return d.equals(str);
    }

    public static String c(String str) {
        BufferedReader bufferedReader;
        try {
            Runtime runtime = Runtime.getRuntime();
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("getprop ");
            stringBuilder.append(str);
            bufferedReader = new BufferedReader(new InputStreamReader(runtime.exec(stringBuilder.toString()).getInputStream()), 1024);
            try {
                str = bufferedReader.readLine();
                bufferedReader.close();
                a.q(bufferedReader);
                return str;
            } catch (Throwable unused) {
                a.q(bufferedReader);
                return null;
            }
        } catch (Throwable unused2) {
            bufferedReader = null;
            a.q(bufferedReader);
            return null;
        }
    }

    public static boolean d() {
        return b("MIUI");
    }

    public static boolean e() {
        return b("VIVO");
    }

    public static boolean f() {
        l();
        return b(a);
    }

    public static String g() {
        if (d == null) {
            b("");
        }
        return d;
    }

    public static String h() {
        if (e == null) {
            b("");
        }
        return e;
    }

    public static final String i() {
        String str = Build.MANUFACTURER;
        return str == null ? "" : str.trim();
    }

    public static boolean j() {
        m();
        return "V10".equals(g);
    }

    public static boolean k() {
        m();
        return "V11".equals(g);
    }

    public static void l() {
        if (TextUtils.isEmpty(a)) {
            a = e.b;
            b = a.d(a.g("ro.build.version."), e.c, "rom");
            c = a.d(a.g("com."), e.c, ".market");
        }
    }

    public static void m() {
        if (g == null) {
            try {
                g = c("ro.miui.ui.version.name");
            } catch (Exception e) {
                e.printStackTrace();
            }
            String str = g;
            if (str == null) {
                str = "";
            }
            g = str;
        }
    }
}
